# 创建一个打乱顺序的整数数组
arr = [3,4,2,1,6,5,7,9,8,0]
       
# 使用插入排序对数组进行排序
for i in range(1,len(arr)):
    key = arr[i]
    j = i-1
    while j>=0 and key<arr[j]:
        arr[j+1] = arr[j]
        j = j-1
    arr[j+1] = key

print(arr)

arr = [3,4,2,1,6,5,7,9,8,0]

# 使用快速排序
def quickSort(arr,low,high):
    if low<high:
        pivot = partition(arr,low,high)
        quickSort(arr,low,pivot-1)
        quickSort(arr,pivot+1,high)

def partition(arr,low,high):
    pivot = arr[low]
    while low<high:
        while low<high and arr[high]>=pivot:
            high = high-1
        arr[low] = arr[high]
        while low<high and arr[low]<=pivot:
            low = low+1
        arr[high] = arr[low]
    arr[low] = pivot
    return low

quickSort(arr,0,len(arr)-1)
print(arr)

arr = [3,4,2,1,6,5,7,9,8,0]
# 使用选择排序
for i in range(0,len(arr)-1):
    min = i
    for j in range(i+1,len(arr)):
        if arr[j]<arr[min]:
            min = j
    if min!=i:
        temp = arr[i]
        arr[i] = arr[min]
        arr[min] = temp
print(arr)
